package com.guigu.serviceorder.mapper;

import com.guigu.serviceorder.entity.OrderItemLog;
import com.guigu.serviceorder.entity.TbOrderItem;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import org.apache.ibatis.annotations.Select;

import java.util.List;

/**
 * <p>
 *  Mapper 接口
 * </p>
 *
 * @author jobob
 * @since 2020-07-08
 */
public interface TbOrderItemMapper extends BaseMapper<TbOrderItem> {

    /**
     * 查询当前用户的所有订单
     * @param username
     * @return
     */
    @Select("SELECT * FROM tb_order_item item INNER JOIN tb_order  ON item.order_id=tb_order.id where username = #{username} AND is_delete =0")
    List<OrderItemLog> OrderItemLogList(String username);


    /**
     * 查询当前用户未支付的订单
     * @param username
     * @return
     */
    @Select("SELECT * FROM tb_order_item item INNER JOIN tb_order  ON item.order_id=tb_order.id WHERE pay_status = 0 AND is_delete =0 and username = #{username}")
    List<OrderItemLog> orderPayList(String username);


    /**
     * 查询当前用户未确认收货的订单
     * @param username
     * @return
     */
    @Select("SELECT * FROM tb_order_item item INNER JOIN tb_order  ON item.order_id=tb_order.id WHERE order_status = 1 and pay_status = 1 and  consign_status = 1 AND is_delete =0 and username = #{username}")
    List<OrderItemLog> orderReceiveList(String username);

    /**
     * 查询当前用户未发货的订单
     * @param username
     * @return
     */
    @Select("SELECT * FROM tb_order_item item INNER JOIN tb_order  ON item.order_id=tb_order.id WHERE pay_status = 1 and  consign_status = 0 AND is_delete =0 and username = #{username}")
    List<OrderItemLog> centerOrderSend(String username);
}
